#include <bits/stdc++.h>
// 2025/01/28
// tag: Math Fermat's Little Theorem Quick Pow 
// Author: Zhang Muen
using namespace std;

#define int int64_t

const int maxn = 8001;
int a, b;
bool is_prime[maxn];
vector<int> prime, cnt;

void get_prime(){
    for (int i = 2; i < maxn; i++){
        if (!is_prime[i])
            prime.push_back(i), cnt.push_back(0);
        for (int j = 0; j < prime.size() && i * prime[j] < maxn; j++){
            is_prime[i * prime[j]] = true;
            if (i % prime[j] == 0)
                break;
        }
    }
}

int quick_pow(int x, int n, int m)
{
    int res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}

bool isprime(int x){
    if (x < maxn)
        return !is_prime[x];
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}

signed main()
{
    get_prime();
    cin >> a >> b;
    for (int i = 0; i < prime.size(); i++)
        while (a % prime[i] == 0)
            a /= prime[i], cnt[i]++;
    for (int i = 0; i < prime.size(); i++)
        cnt[i] = cnt[i] * b;
    int ans = 1;
    for (int i = 0; i < prime.size(); i++){
        ans *= (quick_pow(prime[i], cnt[i] + 1, 9901) - 1);
        ans *= quick_pow(prime[i] - 1, 9899, 9901);
        ans = (ans + 9901) % 9901;
    }
    if (a != 1){
        if (a % 9901 == 1)
            ans *= (b + 1) % 9901;
        else
            ans *= (quick_pow(a, b + 1, 9901) - 1) * quick_pow(a - 1, 9899, 9901);
    }
    cout << (ans + 9901) % 9901 << endl;
    return 0;
}